<!DOCTYPE html>
<html>
<head>
    {include file="_Fragment/meta" /}
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value="">开班状态</option>
                            <option value="1">未开始</option>
                            <option value="2">进行中</option>
                            <option value="3">已结束</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <select name="teacherid">
                            <option value="">教员</option>
                            {volist name="teacher" id="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="time" id="date" placeholder="开课时间" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-inline">
                    <div class="layui-input-inline">
                        <input type="text" name="keys" placeholder="请输入关键字" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="user-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="user-table" lay-filter="user-table"></table>
    </div>
</div>

{include file="_Fragment/javascript" /}
<script>
    layui.use(['table', 'form', 'jquery','common', 'laydate'], function() {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;
        let laydate = layui.laydate;

        laydate.render({
            elem: '#date'
            ,trigger: 'click'
            ,type: 'date'
        });

        let cols = [
            [
                {
                    title: 'Courseid',
                    field: 'courseid',
                    align: 'center',
                    fixed: 'left',
                    width:'10%'
                },
                {
                    title: '课程标题',
                    field: 'e_seminar',
                    align: 'center',
                    fixed: 'left',
                    width:'20%'
                },
                {
                    title: 'Session时间',
                    field: 'time',
                    align: 'center',
                    width:'20%'
                },
                {
                    title: 'Session状态',
                    field: 'status_name',
                    align: 'center',
                    width:'10%'
                },
                {
                    title: '教员',
                    field: 'teacher_name',
                    align: 'center',
                    width:'20%'
                },
                {
                    title: '学员数',
                    field:'members_num',
                    align: 'center',
                    width:'10%'
                },
                {
                    title: '出勤率',
                    field:'chuqin',
                    align: 'center',
                    width:'10%'
                }
            ]
        ]

        table.render({
            elem: '#user-table',
            url: '/ClassesTotal/load',
            page: {layout:['count', 'prev', 'page', 'next', 'skip']},
            limit: 10,
            cols: cols,
            //skin: 'line',
            toolbar: '#user-toolbar',
            defaultToolbar: [{
                title: '刷新',
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter']
        });
        form.on('submit(user-query)', function(data) {
            table.reload('user-table', {
                where: data.field
                ,page: {
                    curr: 1, //重新从第 1 页开始
                    layout:['count', 'prev', 'page', 'next', 'skip']
                }
                ,limit: 10,
            })
            return false;
        });



        table.on('toolbar(user-table)', function(obj) {
            if (obj.event === 'refresh') {
                window.refresh();
            }
        });

        window.refresh = function(param) {
            table.reload('user-table');
        }
    })
</script>
</body>
</html>
